<?php
namespace app\index\common;
use app\extra\weibo\SaeTClientV2;
use app\extra\weibo\SaeTOAuthV2;
class OAuthcommon{

    function Weibourl(){
        //微博登录开始
        header('Content-Type: text/html; charset=UTF-8');
        define("WB_AKEY", '3790507299');
        define("WB_SKEY", 'e5e2de2f566aa4edf9ce53c35c594fc0');
        define("WB_CALLBACK_URL", 'http://blog.mchyweb.top/thinkphp-practice/public/index/index/weibocallback.php');
        $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );

        $code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );
        return $code_url;
    }

    function Weiboinfo(){
        if(isset($_SESSION['token'])) {
            $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
            $ms = $c->home_timeline(); // done
            $uid_get = $c->get_uid();
            $uid = $uid_get['uid'];
            $user_message = $c->show_user_by_id($uid);//根据ID获取用户等基本信息
            return $user_message;
        }
    }
}